﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.controls {
    import flash.events.*;
    import reprise.core.*;

    public class RadioButtonGroup extends EventDispatcher {

        protected var m_selectedIndex:int = -1
        protected var m_radioButtons:Array;
        protected var m_name:String;

        protected static var g_radioGroups:Object;

        public function RadioButtonGroup(_arg1:String){
            m_name = _arg1;
            m_radioButtons = [];
        }
        public function selectRadioButtonWithData(_arg1):void{
            var _local3:RadioButton;
            var _local2:int = m_radioButtons.length;
            while (_local2--) {
                _local3 = (m_radioButtons[_local2] as RadioButton);
                if (_local3.data() == _arg1){
                    setRadioButtonSelected(_local3, true);
                    return;
                };
            };
        }
        public function setRadioButtonSelected(_arg1:RadioButton, _arg2:Boolean):void{
            var _local5:RadioButton;
            var _local3:int = m_selectedIndex;
            if (!_arg2){
                _arg1.setSelected(false);
                return;
            };
            var _local4:uint;
            while (_local4 < m_radioButtons.length) {
                _local5 = (m_radioButtons[_local4] as RadioButton);
                (m_radioButtons[_local4] as RadioButton).setSelected((_local5 == _arg1));
                if (_local5 == _arg1){
                    m_selectedIndex = _local4;
                };
                _local4++;
            };
            if (m_selectedIndex != _local3){
                dispatchEvent(new Event(Event.CHANGE));
            };
        }
        public function selectPreviousButton(_arg1:RadioButton):void{
            var _local3:RadioButton;
            var _local2:int = m_radioButtons.indexOf(_arg1);
            if (_local2 > 0){
                _local3 = m_radioButtons[(_local2 - 1)];
                setRadioButtonSelected(_local3, true);
            };
        }
        public function selectNextButton(_arg1:RadioButton):void{
            var _local3:RadioButton;
            var _local2:int = m_radioButtons.indexOf(_arg1);
            if (_local2 < (m_radioButtons.length - 1)){
                _local3 = m_radioButtons[(_local2 + 1)];
                setRadioButtonSelected(_local3, true);
            };
        }
        public function removeRadioButton(_arg1:RadioButton):void{
            m_radioButtons.splice(m_radioButtons.indexOf(_arg1), 1);
        }
        public function name():String{
            return (m_name);
        }
        public function addRadioButton(_arg1:RadioButton):void{
            m_radioButtons.push(_arg1);
        }
        public function radioButtons():Array{
            return (m_radioButtons);
        }
        public function reset():void{
            var _local2:RadioButton;
            var _local1:int;
            while (_local1 < m_radioButtons.length) {
                _local2 = (m_radioButtons[_local1] as RadioButton);
                _local2.setSelected(false);
                _local1++;
            };
            m_selectedIndex = -1;
        }
        public function selectedRadioButton():RadioButton{
            return (m_radioButtons[m_selectedIndex]);
        }
        public function selectedData(){
            if (m_selectedIndex == -1){
                return (null);
            };
            return ((m_radioButtons[m_selectedIndex] as RadioButton).data());
        }
        public function activatePreviousButton(_arg1:RadioButton):void{
            var _local2:int = m_radioButtons.indexOf(_arg1);
            if (_local2 > 0){
                _arg1.document.setFocusedElement(RadioButton(m_radioButtons[0]), FocusManager.FOCUS_METHOD_KEYBOARD);
            };
        }
        public function activateNextButton(_arg1:RadioButton):void{
            var _local2:int = m_radioButtons.indexOf(_arg1);
            if (_local2 < (m_radioButtons.length - 1)){
                _arg1.document.setFocusedElement(RadioButton(m_radioButtons[(_local2 + 1)]), FocusManager.FOCUS_METHOD_KEYBOARD);
            };
        }

        public static function groupWithName(_arg1:String):RadioButtonGroup{
            if (!g_radioGroups){
                g_radioGroups = {};
            };
            if (!g_radioGroups[_arg1]){
                g_radioGroups[_arg1] = new RadioButtonGroup(_arg1);
            };
            return (g_radioGroups[_arg1]);
        }

    }
}//package reprise.controls 
